package com.neusoft.yiyang.care.controller;

import com.neusoft.yiyang.common.entity.care.CareLevel;
import com.neusoft.yiyang.care.service.CareLevelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "护理级别管理接口", description = "负责护理级别的增删改查操作，支持护理服务标准配置")
@RestController
@RequestMapping("/care-levels")
public class CareLevelController {

    @Autowired
    private CareLevelService careLevelService;

    @Operation(summary = "获取所有护理级别", description = "查询系统中所有的护理级别信息，包含名称、启用状态等")
    @GetMapping("/all")
    public List<CareLevel> getAllCareLevels() {
        return careLevelService.getAllCareLevels();
    }

    @Operation(summary = "根据ID获取护理级别", description = "通过护理级别ID查询具体的级别详情")
    @GetMapping("/{careLevelId}")
    public CareLevel getCareLevelById(
            @Parameter(description = "护理级别ID", required = true) @PathVariable Integer careLevelId) {
        return careLevelService.getCareLevelById(careLevelId);
    }

    @Operation(summary = "添加新的护理级别", description = "新增护理级别信息（如级别名称、启用状态、层级等）")
    @PostMapping("/add")
    public void addCareLevel(
            @Parameter(description = "护理级别信息", required = true) @RequestBody CareLevel careLevel) {
        careLevelService.addCareLevel(careLevel);
    }

    @Operation(summary = "更新护理级别", description = "根据ID修改护理级别的信息（如名称、状态等）")
    @PutMapping("/{careLevelId}")
    public void updateCareLevel(
            @Parameter(description = "护理级别ID", required = true) @PathVariable Integer careLevelId,
            @Parameter(description = "更新后的护理级别信息", required = true) @RequestBody CareLevel careLevel) {
        careLevel.setCareLevelId(careLevelId);
        careLevelService.updateCareLevel(careLevel);
    }

    @Operation(summary = "删除护理级别", description = "根据ID删除指定的护理级别（若已关联项目或老人，可能无法删除）")
    @DeleteMapping("/{careLevelId}")
    public void deleteCareLevel(
            @Parameter(description = "护理级别ID", required = true) @PathVariable Integer careLevelId) {
        careLevelService.deleteCareLevel(careLevelId);
    }
}